﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SGRapidForm.Permission.Service.Interface;
using SGRapidForm.Permission.Entity;
using SGRapidForm.Permission.Component;
using System.Collections.Specialized;
using SGRapidForm.Common;
using System.Data;
using Microsoft.Practices.Unity;

namespace SGRapidForm.Permission.Service
{
    public partial class PermissionService : IPermissionService
    {
        [Dependency]
        public UserRoleComponent UserRoleComponent
        { get; set; }

        /// <summary>
        /// 为用户分配角色
        /// </summary>
        /// <param name="userRole">用户角色明细</param>
        /// <returns></returns>
        public bool UserRole_Add(UserRole userRole)
        {
            return this.UserRoleComponent.UserRole_Add(userRole);
        }

        /// <summary>
        /// 为用户添加岗位
        /// </summary>
        /// <param name="userRoles">用户岗位集合</param>
        /// <returns></returns>
        public bool UserRole_BulkAdd(List<UserRole> userRoles)
        {
            return this.UserRoleComponent.UserRole_BulkAdd(userRoles);
        }

        /// <summary>
        /// 为用户移除角色
        /// </summary>
        /// <param name="userKeyid">用户Keyid</param>
        /// <param name="roleKeyid">角色Keyid</param>
        /// <returns></returns>
        public bool UserRole_Delete(string userKeyid, string roleKeyid)
        {
            return this.UserRoleComponent.UserRole_Delete(userKeyid, roleKeyid);
        }

        /// <summary>
        /// 为用户批量移除角色
        /// </summary>
        /// <param name="userKeyid">用户Keyid</param>
        /// <param name="roleKeyid">角色Keyid集合</param>
        /// <returns></returns>
        public bool UserRole_BulkDelete(string userKeyid, string[] roleKeyids)
        {
            return this.UserRoleComponent.UserRole_BulkDelete(userKeyid, roleKeyids);
        }

        /// <summary>
        /// 用户是否拥有此角色
        /// </summary>
        /// <param name="userKeyid">用户Keyid</param>
        /// <param name="roleKeyid">角色Keyid</param>
        /// <returns></returns>
        public bool UserRole_Exists(string userKeyid, string roleKeyid)
        {
            return this.UserRoleComponent.UserRole_Exists(userKeyid, roleKeyid);
        }

        /// <summary>
        /// 查询已经分配给指定用户的角色
        /// </summary>
        /// <param name="userKeyid">用户Keyid</param>
        /// <returns></returns>
        public List<Role> UserRole_GetRoleByUserKeyid(string userKeyid)
        {
            return this.UserRoleComponent.UserRole_GetRoleByUserKeyid(userKeyid);
        }

        /// <summary>
        /// 查询未分配给指定用户的角色
        /// </summary>
        /// <param name="userKeyid">用户Keyid</param>
        /// <returns></returns>
        public List<Role> UserRole_GetUnmappedRoleByUserKeyid(string userKeyid, string filterConditions)
        {
            return this.UserRoleComponent.UserRole_GetUnmappedRoleByUserKeyid(userKeyid, filterConditions);
        }


        public List<UserRole> UserRole_GetByUserKeyid()
        {
            return this.UserRoleComponent.UserRole_GetByUserKeyid();
        }
    }
}
